package utils;

import java.io.RandomAccessFile;
import persistencia.Grabable;
import persistencia.Register;

public class FileRegister implements Grabable {
	private String filePath;

	public FileRegister() {
	}

	public FileRegister(String filePath) {
		this.filePath = filePath;
	}

	@Override
	public int compareTo(Grabable o) {
		FileRegister f = (FileRegister) o;
		return this.filePath.compareTo(f.filePath);
	}

	@Override
	public void grabar(RandomAccessFile a) {
		Register.writeString(a, filePath, 200);
	}

	@Override
	public void leer(RandomAccessFile a) {
		filePath = Register.readString(a, 200).trim();
	}

	@Override
	public int sizeOf() {
		return 400;
	}

	public int hashCode() {
		return filePath.hashCode();
	}

	public boolean equals(Object o) {
		if (o == null)
			return false;
		FileRegister f = (FileRegister) o;
		return filePath.equals(f.filePath);
	}

	public String getFilePath() {
		return filePath;
	}

	public void setFilePath(String filePath) {
		this.filePath = filePath;
	}
}
